#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N=100010;
int n,m,l,vm;
pair< double,double> di[N],de[N];
int cnt;
int s[N];
int p[N];
bool b[N],is[N];
double as(int v,int a){
    return (double)(vm*vm-v*v)/2/a;
}
int tfind(double d){
    int l=1,r=n;
    while(l<r){
        int mid=l+r>>1;
        if((double)p[mid]<d)l=mid+1;
        else r=mid;
    }
    return l;
}
int main(){
    //freopen("detect.in","r",stdin);
    //freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        int ans1=0,ans2=0;
        scanf("%d%d%d%d",&n,&m,&l,&vm);
        for(int i=1;i<=n;i++){
            int d,v,a;
            scanf("%d%d%d",&d,&v,&a);
            if(a<0&&v>=vm)di[i]={d,min(d+as(v,a),(double)l)};
            else if(a>0)di[i]={max((double)d,d+as(v,a)),(double)l};
            else if(a==0&&v>vm)di[i]={d,l};
            else di[i]={-1,-1};
        }
        sort(di+1,di+n+1);
        for(int i=1;i<=m;i++){
            scanf("%lf",&p[i]);
        }
        for(int i=1;i<=n;i++){
            if(di[i].x==-1)continue;
            int t=tfind(di[i].x);
            if(p[t]<=di[i].y)ans1++,b[i]=1;
        }
        for(int i=1;i<=n;i++){
            if(di[i].x==-1||b[i]==0)continue;
            if(cnt!=0||de[cnt].y>=di[i].y)de[cnt]=di[i];
            else if(de[cnt].x!=di[i].x)de[++cnt]=di[i];
        }
        for(int i=1;i<=cnt;i++){
            int t=tfind(de[i].y)-1;
            ans2++;
            while(i+1<=cnt&&de[i+1].x<=p[t]&&de[i+1].y>=p[t])i++;
        }
        printf("%d %d\n",ans1,m-ans2);
    }
    return 0;
}
